/*
 * @Copyright: 2016 www.yyfax.com Inc. All rights reserved.
 */
package com.jaws.core.compatible.service;

import com.jaws.core.compatible.enums.SequenceStrategy;


/**
 * 生成ID的算法
 * 
 * @author jiangmy
 * @date 2016-12-02 14:38:23
 * @since v1.0.0
 */
public interface SequenceService {
	/**
	 * 32位uuid
	 * 
	 * @author jiangmy
	 * @date 2016-12-02 15:00:17
	 * @since v1.0.0
	 * @return
	 */
	public String uuid32();

	/**
	 * 16位uuid
	 * 
	 * @author jiangmy
	 * @date 2016-12-02 15:00:41
	 * @since v1.0.0
	 * @return
	 */
	public String uuid16();

	/**
	 * 有序的32位uuid串,每秒支持2.4亿个有序记录,超过会乱序.
	 * 
	 * @author jiangmy
	 * @date 2016-12-02 15:02:19
	 * @since v1.0.0
	 * @return
	 */
	public String uuidTimestamped32();

	/**
	 * 有序的32位uuid串,每秒支持6kw个有序记录,超过会乱序.
	 * 
	 * @author jiangmy
	 * @date 2016-12-02 15:02:19
	 * @since v1.0.0
	 * @return
	 */
	public String uuidSerail32();

	/**
	 * 挂在key下的有序id
	 * 
	 * @author jiangmy
	 * @date 2016-12-02 15:08:20
	 * @since v1.0.0
	 * @param key 通常是数据库表名
	 * @return
	 */
	public int sequenceId(String key);

	/**
	 * 带前缀的有序串
	 * 
	 * @author jiangmy
	 * @date 2016-12-02 16:47:30
	 * @since v1.0.0
	 * @param key
	 * @param prefix
	 * @param step
	 * @param len
	 * @return
	 */
	public String sequenceStr(String key, String prefix, int step, int len);

	/**
	 * 根据策略生成业务主键
	 * 
	 * @author jiangmy
	 * @date 2016-12-02 17:16:36
	 * @param strategy
	 * @return
	 */
	public String sequenceStr(SequenceStrategy strategy);

	/**
	 * @author jiangmy
	 * @date 2017年6月9日 下午5:03:25
	 * @since v1.0.0
	 *
	 * @param namespace
	 * @param step
	 * @return
	 */
	int sequenceId(String namespace, int step);
}
